<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>查看运单</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../plugins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="../plugins/layui/css/myPage.css">
    <style>
        .thumb {width:220px;height: 200px}

    </style>
</head>
<body  >
<div class="layui-container">


    <form class="layui-form" >
        <div class="layui-row" id="applyBack">
            <div class="layui-col-md12" >

                <fieldset class="layui-elem-field" style="margin-top: 20px;">
                    <legend id="backtitle"></legend>


                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 90px"  >运单号 </label>
                        <div class="layui-input-inline" style="width: 150px;">
                            <input   type="text" name="ydh"   lay-verify="" placeholder="请输入" id="ydh" class="layui-input" disabled="disabled" >
                            <input   type="hidden" name="bcid"    id="bcid"  >

                            <input   type="hidden" name="ydid"  >
                            <input   type="hidden" name="ydzt" id="ydztValue" >
                            <input   type="hidden" name="sfcz" value="1"  >
                            <input   type="hidden" name="sfscdd" value="1"  >
                            <input   type="hidden" name="comefrom"  id="comefrom"  >
                        </div>



                        <div class="layui-inline">
                            <label class="layui-form-label" style="width: 90px" >当前状态</label>
                            <div class="layui-input-inline" style="width: 150px;">
                                <select name="ydzt"  lay-verify="" disabled="disabled" >
                                    <option value="已报账">已报账</option>
                                    <option value="待调度">待调度</option>
                                    <option value="待发车">待发车</option>
                                    <option value="已发车">已发车</option>
                                    <option value="已回车">已回车</option>
                                    <option value="已完成">已完成</option>
                                    <option value="审核中">审核中</option>
                                    <option value="已报">已报</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label" style="width: 90px" >申请退回状态</label>
                            <div class="layui-input-inline" style="width: 150px;">
                                <select name="sqthzt"  lay-verify=""  id="applybackstau">



                                </select>
                            </div>
                        </div>

                        <div class="layui-inline"  >
                            <input type="hidden" name="errorpic" autocomplete="off" class="layui-input" id="errorpic">

                            <button type="button" class="layui-btn layui-btn-normal "   id="errorpicBtn">上传照片</button>
                            <button type="button" class="layui-btn layui-btn-normal  "   id="lookerrorpicBtn" style="display: none">查看照片</button>
                        </div>
                        <div class="layui-inline"  >
                            <button type="button" class="layui-btn layui-btn-normal  "  style="display: none" id="delerrorpicBtn">删除照片</button>
                        </div>

                    </div>
                    <div class="layui-form-item">

                        <label class="layui-form-label"><span style="color: red;">*</span>申请原因</label>
                        <div class="layui-input-block" style="width: auto ;">
                            <textarea  style="height: auto" class="layui-textarea" name="sqyy"  required  lay-verify="required" placeholder="请输入"     ></textarea>
                        </div>

                    </div>


                    <div class="layui-form-item" style="position: relative;left: 50%">


                        <label class="layui-form-label" style="width: 90px" disabled="disabled">申请人</label>
                        <div class="layui-input-inline" style="width: 150px;">
                            <input   type="text" name="sqr" id="sqr"disabled  lay-verify="" placeholder="请输入"  class="layui-input"  >
                        </div>


                        <label class="layui-form-label" style="width: 90px">申请日期</label>
                        <div class="layui-input-inline" style="width: 150px;">
                            <input   type="text" name="sqrq" id="sqrq"   lay-verify="" placeholder="请输入"  class="layui-input" disabled="disabled" >
                        </div>

                    </div>



                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: auto">注意：运单一旦退回至某状态，其流转期间产生的相关数据均会删除，如，运单由“已发车”退回至“待调度”，则关联的“车牌号”将删除！</label>
                        <div class="layui-input-inline" >
                            <button id="modiSub" class="layui-btn layui-btn-normal  " style="position: absolute ;right: -60px"  lay-submit lay-filter="update"  >立即提交</button>
                        </div>
                    </div>
                    <!--<div class="layui-form-item">-->
                    <!--<div class="layui-input-block" style="position: relative;left: 370px">-->

                </fieldset>

            </div>
        </div>
    </form>
    <div id="checkHis">
        <fieldset id="checkHisfiled" style="display: none" class="layui-elem-field layui-field-title"><legend   style='height:2px;color:black'>退回历史记录</legend></fieldset>
    </div>
</div>



<script src="../plugins/layui/layui.js"></script>
<script src="../js/config.js"></script>
<script src="../js/tools.js"></script>
<script>
    layui.use(['table','form','layer','laydate','upload'],function () {

        var form = layui.form;
        var $ = layui.$;
        var layer = layui.layer;
        var laydate = layui.laydate;
        var upload = layui.upload;
        // console.log($("#comefrom").val())
        $("#bcid").val(uuid());

        switch($("#comefrom").val()){
            case "ddd":
                $("#backtitle").html("车辆待调度退回");
                var option = "<option value=\"订单_待发布\" selected>待发布</option>";
                $("#applybackstau").append(option);
                form.render('select');
                break;
            case "dd":
                  $("#backtitle").html("车辆调度退回");
                  var option =  "<option value=\"订单_待发布\" selected>待发布</option>" +
                                "<option value=\"调度_待发车\" selected>待发车</option>";
                  $("#applybackstau").append(option);
                    form.render('select');
                break;
            case "dj":
                $("#backtitle").html("回车登记退回");
                var option =  "<option value=\"登记_待发布\" selected>待发布</option>"+
                              "<option value=\"登记_待发车\" selected>待发车</option>" +
                              "<option value=\"登记_已发车\" selected>已发车</option>";
                $("#applybackstau").append(option);
                form.render('select');
                break;
            case "bz":
                $("#backtitle").html("回车报账退回");
                var option =  "<option value=\"报账_待发布\" selected>待发布</option>"+
                              "<option value=\"报账_已发车\" selected>已发车</option>"+
                              "<option value=\"报账_待发车\" selected>待发车</option>" +
                              "<option value=\"报账_已回车\" selected>已回车</option>";
                $("#applybackstau").append(option);
                form.render('select');
                break;
            case "kj":
                var option =  "<option value=\"快捷_撤销\" selected>撤销</option>";
                $("#applybackstau").append(option);
                $("#backtitle").html("快捷运单退回");
                form.render('select');
                break;
        }

        if($("#ydztValue").val() == "审核中"){
            $("#applyBack").css("display","none");
            $("#checkHisfiled").css("display","block");
        }else{

        }

        uploadOneFile(upload,$,layer,"errorinfo",$("#bcid").val(),"errorpic");

        var delFileArr = new Array();

        delFile($,layer,"errorpic",delFileArr);

        lookFile($,layer,"errorpic");

//渲染历史退回
        $.ajax({
            url: contextPath+"/error/"+$("#ydh").val(),
            type: "GET",
            contentType:"application/json;charset=utf-8",
            dataType:"json",
            success: function(res) {
                // console.log(res.list)
                if(res.list.length > 0 && $("#ydztValue").val() != "审核中"){
                    $("#checkHisfiled").css("display","block");
                }
                $.each(res.list,function (i,e) {


                    switch(e.sqthzt.toString().split('_')[0]){
                        case "订单":
                            e.title1 = ("车辆待调度退回");
                            e.title2 = ("车辆待调度审核");
                            break;
                        case "调度":
                            e.title1 = ("车辆调度退回");
                            e.title2 = ("车辆调度审核");
                            break;
                        case "登记":
                            e.title1 =("回车登记退回");
                            e.title2 =("回车登记审核");
                            break;
                        case "报账":
                            e.title1 =("回车报账退回");
                            e.title2 =("回车报账审核");
                            break;
                        case "快捷":
                            e.title1 =("快捷运单退回");
                            e.title2 =("快捷运单审核");
                            break;
                    }

                    var oneError = "  <div class=\"layui-row\">\n" +
                        "            <div class=\"layui-col-md12\">\n" +
                        "\n" +
                        "                <fieldset class=\"layui-elem-field\" style=\"margin-top: 20px;\">\n" +
                        "                    <legend>"+e.title1+"</legend>\n" +
                        "\n" +
                        "\n" +
                        "                    <div class=\"layui-form-item\">\n" +
                        "                        <label class=\"layui-form-label\" style=\"width: 90px\"  >运单号 </label>\n" +
                        "                        <div class=\"layui-input-inline\" style=\"width: 150px;\">\n" +
                        "                            <input   type=\"text\" name=\"ydh\"   lay-verify=\"\" placeholder=\"请输入\"  class=\"layui-input\" disabled=\"disabled\" value="+ e.ydh +" >\n" +
                        "\n" +
                        "                            <input   type=\"hidden\" name=\"ydid\"  >\n" +
                        "                            <input   type=\"hidden\" name=\"sfcz\" value=\"1\"  >\n" +
                        "                            <input   type=\"hidden\" name=\"sfscdd\" value=\"1\"  >\n" +
                        "                        </div>\n" +
                        "\n" +
                        "                        <div class=\"layui-inline\">\n" +
                        "                            <label class=\"layui-form-label\" style=\"width: 90px\" >当前状态</label>\n" +
                        "                            <div class=\"layui-input-inline\" style=\"width: 150px;\">\n" +
                        "                                <input name=\"ydzt\" class=\"layui-input\" lay-verify=\"\" disabled=\"\" value="+ e.ydzt+" >\n" +
                        "                                </input>\n" +
                        "                            </div>\n" +
                        "                        </div>\n" +
                        "                        <div class=\"layui-inline\">\n" +
                        "                            <label class=\"layui-form-label\" style=\"width: 90px\" >申请退回状态</label>\n" +
                        "                            <div class=\"layui-input-inline\" style=\"width: 150px;\">\n" +
                        "                                <input name=\"sqthzt\"  lay-verify=\"\" class=\"layui-input\" disabled=\"\"value=" + e.sqthzt.toString().split('_')[1]+ ">\n" +
                        "                                </input>\n" +
                        "                            </div>\n" +
                        "                        </div>\n" +
                        "                    </div>\n" +
                        "                    <div class=\"layui-form-item\">\n" +
                        "                        <label class=\"layui-form-label\"><span style=\"color: red;\">*</span>申请原因</label>\n" +
                        "                        <div class=\"layui-input-block\" style=\"width: auto ;\">\n" +
                        "                            <textarea  style=\"height: auto\" class=\"layui-textarea\" name=\"sqyy\"  required  lay-verify=\"required\" disabled=\"\" placeholder=\"请输入\"> "+ e.sqyy+"</textarea>\n" +
                        "                        </div>\n" +
                        "\n" +
                        "                    </div>\n" +
                        "\n" +


                        "                    <div class=\"layui-form-item\" style=\"position: relative;left: 50%\">\n" +
                        "                        <label class=\"layui-form-label\" style=\"width: 90px\" >申请人</label>\n" +
                        "                        <div class=\"layui-input-inline\" style=\"width: 150px;\">\n" +
                        "                            <input   type=\"text\" name=\"sqr\"   lay-verify=\"\" placeholder=\"请输入\"  class=\"layui-input\" value=" + e.sqr+" disabled=\"disabled\">\n" +
                        "                        </div>\n" +
                        "\n" +
                        "\n" +
                        "                        <label class=\"layui-form-label\" style=\"width: 90px\">申请日期</label>\n" +
                        "                        <div class=\"layui-input-inline\" style=\"width: 150px;\">\n" +
                        "                            <input   type=\"text\" name=\"sqrq\"     lay-verify=\"\" placeholder=\"请输入\"  class=\"layui-input\" disabled=\"disabled\" value="+e.sqrq+" >\n" +
                        "                        </div>\n" +
                        "\n" +
                        "                    </div>\n" +
                        "\n" +
                        "\n" +
                        "\n" +
                        "                    <div class=\"layui-form-item\">\n" +
                        "                        <label class=\"layui-form-label\" style=\"width: auto\">注意：运单一旦退回至某状态，其流转期间产生的相关数据均会删除，如，运单由“已发车”退回至“待调度”，则关联的“车牌号”将删除！</label>\n" +
                        "\n" +
                        "                    </div>\n" +
                        "                    <!--<div class=\"layui-form-item\">-->\n" +
                        "                    <!--<div class=\"layui-input-block\" style=\"position: relative;left: 370px\">-->\n" +
                        "\n" +
                        "                </fieldset>\n" +
                        "\n" +
                        "            </div>\n" +
                        "        </div>\n" +
                        "        <div class=\"layui-row\">\n" +
                        "            <div class=\"layui-col-md12\">\n" +
                        "\n" +
                        "                <fieldset class=\"layui-elem-field\" style=\"margin-top: 20px;\">\n" +
                        "                    <legend>"+e.title2+"</legend>\n" +
                        "\n" +
                        "\n" +
                        "                    <div class=\"layui-form-item\">\n" +
                        "\n" +
                        "                        <label class=\"layui-form-label\"> 审核结果</label>\n" +
                        "                        <div class=\"layui-inline\">\n" +
                        "                            <input name=\"shjg\" class=\"layui-input\" disabled placeholder='审核中'   lay-verify=\"required\"  value='"+ e.shjg +"'>\n" +
                        "\n" +
                        "                            </input>\n" +
                        "                        </div>\n" +
                        "                        <div class=\"layui-inline\">\n" +
                        "                            <label class=\"layui-form-label\" style=\"width: 90px\" >审核人</label>\n" +
                        "                            <div class=\"layui-input-inline\" style=\"width: 150px;\">\n" +
                        "                                <input name=\"shr\" disabled lay-verify=\"\" class=\"layui-input\"  value='"+e.shr+"'>\n" +
                        "                                </input>\n" +
                        "                            </div>\n" +
                        "                        </div>\n" +
                        "                        <div class=\"layui-inline\">\n" +
                        "                            <label class=\"layui-form-label\" style=\"width: 90px\" >审核日期</label>\n" +
                        "                            <div class=\"layui-input-inline\" style=\"width: 150px;\">\n" +
                        "                                <input name=\"shrq\"  disabled  lay-verify=\"\" class=\"layui-input\"  value='"+ e.shrq+"'>\n" +
                        "                                </input>\n" +
                        "                            </div>\n" +
                        "                        </div>\n" +
                        "\n" +
                        "                    </div>\n" +
                        "\n" +
                        "                </fieldset>\n" +
                        "\n" +
                        "            </div>\n" +
                        "        </div>";


                    $("#checkHis").append(oneError);

                });



            }

    });

        //自动获取经手人
        $.ajax({
            url: contextPath+"/currentUser",
            type: "GET",
            contentType:"application/json;charset=utf-8",
            dataType:"json",
            success: function(res) {
                currentUser = res.yhm;
                // console.log(res);
                $("#sqr").val(currentUser);
            }
        });





        laydate.render({
            elem: '#sqrq' //指定元素
            ,theme:'#0099FF'
            ,value: getFormatDate()
            ,type: 'date'
            ,format:'yyyy-MM-dd'
        });








        form.on('submit(update)', function(data){

            console.log(data.field);
            $("input").css("border","");
            $.ajax({
                url: contextPath+"/error/",
                type: "POST",
                contentType:"application/json;charset=utf-8",
                data: JSON.stringify(data.field) ,
                dataType:"json",
                success: function(res) {
                    updateSuccess($,layer,res)
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    });

</script>
</body>
</html>